package cn.damong.weixin.mp;

import java.io.Serializable;
import java.util.Date;

/**
 * jsapi_ticket是公众号用于调用微信JS接口的临时票据。
 * 正常情况下，jsapi_ticket的有效期为7200秒，需要通过access_token来获取。
 * jsapi_ticket的api调用次数非常有限，频繁刷新jsapi_ticket会导致api调用受限，影响自身业务
 * 开发者必须在自己的服务全局缓存和更新jsapi_ticket
 * 
 * 这个类是jsapi_ticket映射的实体类，用于持久化jsapi_ticket
 * 
 * @author CodingPanda
 * @2019年5月8日 下午11:43:05
 *
 */
public class WeixinJsapiTicket implements Serializable {
    private static final long serialVersionUID = 5774407212628647604L;

    /**
     * 记录id， 由持久化层决定具体含义，一般对应数据库主键id
     */
    private Integer id;

    /**
     * 公众号的唯一标识
     */
    private String appId;

    /**
     * 公众号API密匙, 不安全项，不建议赋值
     */
    private String appSecret;

    /**
     * 调用JS-SDK的临时票据
     */
    private String jsapiTicket;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 过期时间
     */
    private Date expireTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getAppSecret() {
        return appSecret;
    }

    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }

    public String getJsapiTicket() {
        return jsapiTicket;
    }

    public void setJsapiTicket(String jsapiTicket) {
        this.jsapiTicket = jsapiTicket;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(Date expireTime) {
        this.expireTime = expireTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((appId == null) ? 0 : appId.hashCode());
        result = prime * result + ((appSecret == null) ? 0 : appSecret.hashCode());
        result = prime * result + ((createTime == null) ? 0 : createTime.hashCode());
        result = prime * result + ((expireTime == null) ? 0 : expireTime.hashCode());
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        result = prime * result + ((jsapiTicket == null) ? 0 : jsapiTicket.hashCode());
        result = prime * result + ((updateTime == null) ? 0 : updateTime.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        WeixinJsapiTicket other = (WeixinJsapiTicket) obj;
        if (appId == null) {
            if (other.appId != null) {
                return false;
            }
        } else if (!appId.equals(other.appId)) {
            return false;
        }
        if (appSecret == null) {
            if (other.appSecret != null) {
                return false;
            }
        } else if (!appSecret.equals(other.appSecret)) {
            return false;
        }
        if (createTime == null) {
            if (other.createTime != null) {
                return false;
            }
        } else if (!createTime.equals(other.createTime)) {
            return false;
        }
        if (expireTime == null) {
            if (other.expireTime != null) {
                return false;
            }
        } else if (!expireTime.equals(other.expireTime)) {
            return false;
        }
        if (id == null) {
            if (other.id != null) {
                return false;
            }
        } else if (!id.equals(other.id)) {
            return false;
        }
        if (jsapiTicket == null) {
            if (other.jsapiTicket != null) {
                return false;
            }
        } else if (!jsapiTicket.equals(other.jsapiTicket)) {
            return false;
        }
        if (updateTime == null) {
            if (other.updateTime != null) {
                return false;
            }
        } else if (!updateTime.equals(other.updateTime)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "WeixinJsapiTicket [id=" + id + ", appId=" + appId + ", appSecret=" + appSecret + ", jsapiTicket="
                + jsapiTicket + ", createTime=" + createTime + ", expireTime=" + expireTime + ", updateTime="
                + updateTime + "]";
    }

}